# -*- coding: utf-8 -*-
# @Time    : 2021/5/8 9:35
# @Author  : xxue
# @Email   : x_xue1212@163.com
# @File    : ATM.py
# @Software: PyCharm
# -*- coding: utf-8 -*-
# @Time    : 2021/5/6 9:45
# @Author  : lilu
# @Email   : 1906196327@qq.com
# @File    : atm机.py
# @Software: PyCharm


#1、分析atm存取款功能
#两个类： ATM  用户
#ATM：
#属性：  钱，名称，位置
#方法：  放钱进去， 取出atm里面的钱

#用户：
#属性： 账户名，密码，账户金额
#方法： 存钱，取钱，查看金额

class ATM():
    def __init__(self, money, name, location):
        self.money = money
        self.name = name
        self.location = location

    def add_money(self,money):
        print(f"添加金额：{money}")
        self.money += money

    def take_money(self, money):
        print(f"取出金额: {money}")
        self.money -= money

class User():
    def __init__(self, name, passwd, money):
        self.name = name
        self.passwd = passwd
        self.money = money

    def save_money(self, money, atmobj):
        print(f"存入金额:{money}")
        self.money += money
        atmobj.money += money

    def get_money(self, money, atmobj):
        print(f"取出金额：{money}")
        if self.money >= money and atmobj.money >= money:
            self.money -= money
            atmobj.money -= money
        else:
            print("账户或取款机余额不足！")

    def show_money(self):
        print(f"当前账户余额为：{self.money}")

print("欢迎来到三乐ATM取款机".center(30,"="))

atm1 = ATM(10000, "工商银行", "nongda")
atm2 = ATM(20000, "建设银行", "gongda")
user1 = User("lilu", "123456", 50000)
user2 = User("xiayuzhen", "xyz", 50000)

while True:
    print("""            按1查看账户余额
            按2进行取款操作
            按3进行存款操作
            按q退出系统""")

    num = input("请输入您的选项：")
    if num == "1":
        print(f"您的账户余额为{user1.money}")
        print("-"*30)
    if num == "2":
        take_mon = int(input("请输入您需要取款的金额："))
        user1.get_money(take_mon,atm1)
        print("-" * 30)

    if num == "3":
        save_mon = int(input("请输入您需要取款的金额："))
        user1.save_money(save_mon,atm1)
        print("-" * 30)

    if num == "q":
        print("系统退出成功...")
        break
